//
//  DisCoverXuanShangDescTableViewController.m
//  随拍
//
//  Created by lanou3g on 16/1/18.
//  Copyright © 2016年 Ashoka. All rights reserved.
//

#import "DisCoverXuanShangDescTableViewController.h"
#import "UIImageView+WebCache.h"
#import "UMSocial.h"
#import "DisCoverXuanShangDescTableViewCell.h"
#import "DisCoverXuanShangAllPingLunTableViewController.h"
#import "DisCoverThreeLoginViewController.h"
#import "DisCoverYouJIManager.h"
#import "DisCoverXuanShangPingLunViewController.h"
@interface DisCoverXuanShangDescTableViewController ()<UITableViewDataSource,UITableViewDelegate,UMSocialUIDelegate>

@property(nonatomic,strong)UIImageView *nameImgView;

@property(nonatomic,strong)UILabel * nameLabel;

@property(nonatomic,strong)UILabel * timeLabel;

@property(nonatomic,strong)UILabel * titileLabel;

@property(nonatomic,strong)UIImageView * placeImgView;

@property(nonatomic,strong)UILabel * placeLabel;

@property(nonatomic,strong)UIImageView * bigImgView;


@property(nonatomic,strong)UIView * discoverView;

@property(nonatomic,strong)UIView * disfootView;


@property(nonatomic,assign)BOOL hasLoad;



@end

@implementation DisCoverXuanShangDescTableViewController

NSString * identidiscoverxuanshangdesc = @"xuanshangdesccell";


-(instancetype)init{
    
    if (self = [super init]) {
        
        self.hidesBottomBarWhenPushed=YES;
        
        
    }
    
    return self;
}







- (void)viewDidLoad {
    
    [super viewDidLoad];
    
    self.discoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width , 736 - 64 - 60)];
    
    self.disfootView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 40)];
    
    //self.disfootView.backgroundColor = [UIColor redColor];
    
    
    //self.navigationController.navigationBarHidden = NO;
    
    //  self.navigationController.navigationItem.rightBarButtonItem
    
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.nameImgView = [[UIImageView alloc] init];
    
    self.nameImgView.frame = CGRectMake(10, 20, 40, 40);
    
    [_nameImgView sd_setImageWithURL:[NSURL URLWithString:_nameImgViewStr] placeholderImage:nil];
    
    //_nameImgView.backgroundColor = [UIColor redColor];
    
    self.nameLabel = [[UILabel alloc] init];
    
    self.nameLabel.frame = CGRectMake(55, 20, 300, 20);
    //_nameLabel.backgroundColor = [UIColor orangeColor];
    _nameLabel.text = _nameLabelStr;
    
    
    self.timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(55, 40, 200, 20)];
    _timeLabel.text = _timeLabelStr;
    //_timeLabel.backgroundColor = [UIColor redColor];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"分享" style:UIBarButtonItemStylePlain target:self action:@selector(fenxiang:)] ;
    
    
    self.titileLabel = [[UILabel alloc] init];
    self.titileLabel.frame = CGRectMake(10, 65, self.view.frame.size.width -20, 50);
    // _titileLabel.backgroundColor = [UIColor orangeColor];
    _titileLabel.text = _titileLabelStr;
    _titileLabel.font = [UIFont systemFontOfSize:18];
    _titileLabel.numberOfLines = 0;
    
    
    
    self.placeLabel = [[UILabel alloc] init];
    self.placeLabel.frame = CGRectMake(35, 110,self.view.frame
                                       .size.width - 45, 20);
    // self.placeLabel.backgroundColor = [UIColor redColor];
    self.placeLabel.text = _placeLabelStr;
    
    if ([_placeLabelStr isEqualToString:@""]) {
        
    }else{
        self.placeImgView = [[UIImageView alloc] init];
        self.placeImgView.contentMode = UIViewContentModeScaleAspectFit;
        self.placeImgView.frame = CGRectMake(10, 110, 20, 20);
        _placeImgView.image = [UIImage imageNamed:@"cinema"];
        
    }
    
    
    self.bigImgView = [[UIImageView alloc] init];
    
    self.bigImgView.frame = CGRectMake(10, 135, self.view.frame.size.width-20, self.view.frame.size.height - 135 - 49 - 64);
    
    self.bigImgView.contentMode = UIViewContentModeScaleToFill;
    
    [_bigImgView sd_setImageWithURL:[NSURL URLWithString:_bigImgViewStr] placeholderImage:nil];
    
    
    
    self.loginButton = [[UIButton alloc]init];
    _loginButton.backgroundColor = [UIColor clearColor];
    self.loginButton.frame = CGRectMake(5, 5, self.view.frame.size.width - 90, 30);
    _loginButton.backgroundColor = [UIColor cyanColor];
    
    
    UIButton *blbutton = [UIButton buttonWithType:UIButtonTypeSystem];
    
    blbutton.frame = CGRectMake(self.view.frame.size.width - 80, 5, 55, 30);
    [blbutton setTitle:@"全部评论" forState:UIControlStateNormal];
    [blbutton addTarget:self action:@selector(quanbupinglun:) forControlEvents:UIControlEventTouchUpInside];
    //blbutton.backgroundColor = [UIColor blueColor];
    
    
    
    UILabel *alb = [[UILabel alloc] initWithFrame:CGRectMake(10,0 , self.view.frame.size.width - 20, 40)];
    
    alb.layer.borderColor =[[UIColor blackColor] CGColor];
    
    alb.layer.borderWidth = 0.9f;
    
   // alb.backgroundColor = [UIColor cyanColor];
    
    alb.text = @"我来评论";
    
    alb.textAlignment = NSTextAlignmentCenter;
    
    alb.userInteractionEnabled = YES;
    
    [alb addSubview:_loginButton];
    [alb addSubview:blbutton];
    [self.discoverView addSubview:_nameImgView];
    [self.discoverView addSubview:_nameLabel];
    [self.discoverView addSubview:_titileLabel];
    [self.discoverView addSubview:_placeImgView];
    [self.discoverView addSubview:_placeLabel];
    [self.discoverView addSubview:_bigImgView];
    [self.disfootView addSubview:alb];
    [self.discoverView addSubview:_timeLabel];
    
    
    
    [self.loginButton addTarget:self action:@selector(pinglun:) forControlEvents:UIControlEventTouchUpInside];
    
    _discoverView.backgroundColor = [UIColor whiteColor];
    
    self.tableView.tableHeaderView = _discoverView;
    
    self.tableView.tableFooterView = _disfootView;
    
    self.tableView.delegate = self;
    
    self.tableView.dataSource = self;
    
    [self.tableView registerNib:[UINib nibWithNibName:@"DisCoverXuanShangDescTableViewController" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:identidiscoverxuanshangdesc];
    
    
}

-(void)quanbupinglun:(UIButton *)sender{

    NSLog(@"全部评论");
    
    DisCoverXuanShangAllPingLunTableViewController *allpinglu = [[DisCoverXuanShangAllPingLunTableViewController alloc] init];
    
    [self.navigationController pushViewController:allpinglu animated:YES];
    
    

}



-(void)fenxiang:(UIButton *)sender{
    
    
    [UMSocialSnsService presentSnsIconSheetView:self appKey:@"569c8ee1e0f55aec8c000c07" shareText:_titileLabelStr shareImage:_bigImgView.image shareToSnsNames:[NSArray arrayWithObjects:UMShareToSina, UMShareToSms,UMShareToDouban,UMShareToTencent,nil] delegate:self];
    
    
    
}

-(void)pinglun:(UIButton *)sengder{
    
    if ([DisCoverYouJIManager shareDisCoverYouJIManager].loginUserName == nil) {
        
        NSLog(@"模态第三方登陆");
        
        DisCoverThreeLoginViewController *threeLogin = [[DisCoverThreeLoginViewController alloc] init];
        
        [self.navigationController pushViewController:threeLogin animated:YES];
        
    }else{
    
        DisCoverXuanShangPingLunViewController *pinglun = [[DisCoverXuanShangPingLunViewController alloc] init];
        
        [self.navigationController pushViewController:pinglun animated:YES];
    
    
    }
    
    
    
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];

}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return 3;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (!_hasLoad) {
        
        UINib *nib = [UINib nibWithNibName:@"DisCoverXuanShangDescTableViewCell" bundle:nil];
        
        [tableView registerNib:nib forCellReuseIdentifier:identidiscoverxuanshangdesc];
        
        _hasLoad = YES;
        
    }
    
    DisCoverXuanShangDescTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identidiscoverxuanshangdesc forIndexPath:indexPath];
    
   cell.pinglunLabel.text = @"dfdsasdfsaf";
    
    
    
    return cell;
}



-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    
    return 100;
    
}




/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Table view delegate

// In a xib-based application, navigation from a table can be handled in -tableView:didSelectRowAtIndexPath:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic may go here, for example:
    // Create the next view controller.
    <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:<#@"Nib name"#> bundle:nil];
    
    // Pass the selected object to the new view controller.
    
    // Push the view controller.
    [self.navigationController pushViewController:detailViewController animated:YES];
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
